﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ViewModels;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.ComponentModel;

namespace FlashlightRecorder.ViewModels
{
    [DataContract]
    public class Record :INotifyPropertyChanged
    {



        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public MainViewModel Root { get; set; }

        ObservableCollection<LightSpan> _items = new ObservableCollection<LightSpan>();
        [DataMember]
        public ObservableCollection<LightSpan> Items
        {
            get 
            {
                return _items;
            }
            set 
            {
                 _items=value;
                 NotifyPropertyChanged("Items");
            }
        }


        string _name;
        [DataMember]
        public String Name
        {
            get { return _name; }
            set 
            { 
                _name = value;
                NotifyPropertyChanged("Name");
            }
        }



        TimeSpan _duration;

        [DataMember]
        public TimeSpan Duration
        {
            get { return _duration; }
            set { _duration = value; NotifyPropertyChanged("Duration"); }
        }








    }


    [DataContract]
    public class LightSpan : INotifyPropertyChanged
    {


        TimeSpan _start;

        [DataMember]

        public TimeSpan Start
        {
            get { return _start; }
            set { _start = value; NotifyPropertyChanged("Start");  NotifyPropertyChanged("End"); }
        }



        TimeSpan _duration;

        [DataMember]
        public TimeSpan Duration
        {
            get { return _duration; }
            set { _duration = value; NotifyPropertyChanged("Duration"); NotifyPropertyChanged("End"); }
        }


        //[DataMember]
        public TimeSpan End
        {
            get { return _start+_duration; }
           
        } 



        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }


    }

}
